<!DOCTYPE html>
<html lang="en">
<head>
    <title>电子缴库</title>
    <#include "../inc/header.ftl"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <table id="MainGrid"></table>
                        <div id="toolbar">
                            <div style="padding:8px">
                                单据号：<input id="billNum" class="easyui-textbox" style="width:140px">&emsp;
                                <#--交易流水号：<input id="bankaffirmfind" class="easyui-textbox" style="width:140px">&emsp;-->
                                账户：<input id="accountcode"  name="accountcode">&emsp;
                                收款时间：<input id="paybankdt" class="easyui-datebox" style="width:140px">&emsp;
                                <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton"
                                   iconCls="icon-search">查 询</a>
                            </div>
                            <div style="padding:8px 8px 4px">
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:sendInfo(1);">发送划款</a>&nbsp;&nbsp;
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:sendInfo(2);">发送扣款</a>&nbsp;&nbsp;
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:sendInfo(3);">发送票据</a>&nbsp;&nbsp;
                            </div>
                        </div>
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
            <#--修改-->
            <div id="SendBox-add" class="ui-dialog-content hide">
                <div style="padding:8px">
                    复核用户编码：<input id="usercode" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    复核用户密码：<input id="userpwd" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    <input id="biaoshi" hidden>&emsp;
                    <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:pageSendInfo()"><span
                                id="sendClean"></span></a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="javascript:cancelInfo()"><span
                                id="sendCleanCan"></span></a>
                </div>
                <table id="SendMainGrid"></table>
            </div>
        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>

<!-- inline scripts related to this page -->
</body>
</html>






<script type="text/javascript">

    jQuery(function ($) {
        listPage();
    });

    function searchInfo() {
        listPage(prefix + '/bill/epayfisc/selepayfisc', 1)
    }
    function listPage(url,mark) {
        if(mark==1){
            var bankaffirm = $('#bankaffirmfind').val();
            var billNum = $('#billNum').val();
            var accountcode = $('#accountcode').val();
            var paybankdt = $('#paybankdt').val();
            // if(accountcode==null||accountcode==''){
            //     $.messager.alert('提示', '请选择账户', 'info');
            //     return;
            // }
        }

        // 右侧表格
        $('#MainGrid').datagrid({
            //title:'学生列表',
            url: url,
            checkbox: true,
            pagination: true,
            fitColumns: false,
            striped: true,
            singleSelect: false,
            loadMsg: "正在努力加载数据，请稍后...",
            queryParams: {billNum: billNum, accountCode: accountcode, payBankDt: paybankdt},
            columns: [[
                {field: '单据id', checkbox: 'payid',hide:true,width:100 },
                {title: '单据号',  field: 'billNum',width:100},
                {title: '交易流水号', field: 'traNo',  width: 110},
                {title: '付款户名', field: 'accountName',width:100},
                {title: '付款账号', field: 'accountCode',  width: 110 },
                {title: '金额', field: 'money', width: 100},
                {title: '扣款时间', field: 'payBankDt', width: 100},
                {title: '扣款流水号', field: 'bankAffirm', width: 100 },
                {title: '对账批次',  field: 'chkAcctOrd', width: 100},
                {title: '对账日期',  field:'checkDate', width: 110 },
                {title: '划款日期',  field:'paymentDate',  width: 110},
                {title: '退款日期',  field: 'backTime', width: 100 },
                {title: '退款流水号', field: 'backBankAffirm', width: 100}
            ]],
            toolbar: '#toolbar'

        });
        $(window).resize(function () {
            $('#MainGrid').datagrid('resize');
        });
    }
    var list = [];

    //----------------------- 发送弹窗
    function sendInfo(opt) {
        $('#biaoshi').val(opt);
        var tit = '';
        $('#sendClean').text('确认发送');
        $('#sendCleanCan').text('取消发送');
        if(opt == 1) {
            tit='发送划款';
        }else if(opt==2){
            tit='发送扣款';
        }else{
            tit='发送票据';
        }

        var row = $('#MainGrid').datagrid('getSelections');
        if (row.length == 0) {
            $.messager.alert('提示', '请选择要发送的数据', 'info');
            return;
        }

        $("#SendBox-add").removeClass('hide').dialog({
            title: '&nbsp;' + tit,
            iconCls: 'icon-add',
            width: 800,
            height: 500,
            modal: true,
            buttons: [{
                text: '取消',
                iconCls: 'icon-cancel',
                width: 80,
                plain: false,
                handler: function () {
                    $('#SendBox-add').dialog('close')
                }
            }]
        });

        $('#SendMainGrid').datagrid({
            data: row,
            fitColumns: true,
            striped: true,
            loadMsg: "正在加载数据，请稍后...",
            columns: [[
                // {field: '单据id', checkbox: 'payid',hide:true,width:100 },
                {title: '单据号',  field: 'billNum',width:100},
                {title: '交易流水号', field: 'traNo',  width: 110},
                {title: '付款户名', field: 'accountName',width:100},
                {title: '付款账号', field: 'accountCode',  width: 110 },
                {title: '金额', field: 'money', width: 100},
                {title: '扣款时间', field: 'payBankDt', width: 100},
                {title: '扣款流水号', field: 'bankAffirm', width: 100 },
                {title: '对账批次',  field: 'chkAcctOrd', width: 100},
                {title: '对账日期',  field:'checkDate', width: 110 },
                {title: '划款日期',  field:'paymentDate',  width: 110},
                {title: '退款日期',  field: 'backTime', width: 100 },
                {title: '退款流水号', field: 'backBankAffirm', width: 100}
            ]],
        });
    }


    //  ----------------确认发送
    function pageSendInfo() {
        var usercode = $('#usercode').val();
        var userpwd = $('#userpwd').val();
        if (usercode == null || usercode == '') {
            $.messager.alert('提示', '请输入用户编码', 'info');
            return;
        }
        if (userpwd == null || userpwd == '') {
            $.messager.alert('提示', '请输入用户密码', 'info');
            return;
        }
        var opt = $('#biaoshi').val();
        var url ='';
        if(opt==1){
            url ='/bill/epayfisc/sendpayment';
        }else if(opt==2){
            url = '/bill/epayfisc/sendepayFisc';
        }else{
            url='/bill/epayfisc/sendefisc';
        }
        var row = $('#SendMainGrid').datagrid('getData');
        var list = [];
        $.each(row.rows,function(index, value) {
            list.push(value.billNum)
        });

        $.ajax({
            url: prefix + url,
            type: 'POST',
            data: {
                usercode: usercode,
                userpwd: userpwd,
                billid:list.join(',')
            },
            dataType: 'json',
            success: function (data) {
                $.messager.alert('提示', data.msg, 'info');
            }
        });
    }



    function cancelInfo() {
        $('#SendBox-add').dialog('close')
    }


    $('#accountcode').combogrid({
        panelWidth:550,
        idField:'accountcode',
        textField:'accountcode',
        url:prefix+'/base/basedata/findBank',
        columns:[[
            {field: 'ck', checkbox: true},
            {field:'cantonname',title:'区划',width:80},
            {field:'accountcode',title:'账号',width:160},
            {field:'bankname',title:'开户行名称',width:260}
        ]]
    });
</script>
